package com.lagou.homework.service;

import com.lagou.homework.bean.Student;
import com.lagou.homework.dao.StudentManageDao;
import com.lagou.homework.factory.StudentManageDaoFactory;

/**
 * 用于实现StudentManageDao中的方法
 */
public class StudentManageService {

    // 合成复用原则
    private StudentManageDao studentManageDao;

    public StudentManageService() {
        this.studentManageDao = StudentManageDaoFactory.getStudentManageDao();
    }

    /**
     * 实现获取学生信息的方法
     */
    public Student[] getAllStudentsService() {
        return studentManageDao.getAllStudents();
    }

    /**
     * 实现添加学生信息的方法
     */
    public int addStudentService(Student student) {
        return studentManageDao.addStudent(student);
    }

    /**
     * 实现修改学生信息的方法
     */
    public int editStudentService(Student student) {
        return studentManageDao.editStudent(student);
    }

    /**
     * 实现删除学生信息的方法
     */
    public int delStudentService(int code) {
        return studentManageDao.delStudent(code);
    }

    /**
     * 实现查询学生信息的方法
     */
    public Student searchStudentService(int code) {
        return studentManageDao.searchStudent(code);
    }
}
